﻿/*HYQing
==============================================================================================================
*/


$(document).ready(function () {
    function initFrame() {
        var winWidth = 0;
        var winHeight = 0;

        //获取窗口宽度
        if (window.innerWidth)
            winWidth = window.innerWidth;
        else if ((document.body) && (document.body.clientWidth))
            winWidth = document.body.clientWidth;
        //获取窗口高度
        if (window.innerHeight)
            winHeight = window.innerHeight;
        else if ((document.body) && (document.body.clientHeight))
            winHeight = document.body.clientHeight;

        //通过深入Document内部对body进行检测，获取窗口大小
        if (document.documentElement
           && document.documentElement.clientHeight
           && document.documentElement.clientWidth) {
            winHeight = document.documentElement.clientHeight;
            winWidth = document.documentElement.clientWidth;
        }

        //结果输出

        CHeight = winHeight - 180 + "px";
        CWidth = winWidth - 293 + "px";
        document.getElementById("TableContent").style.height = CHeight;
        document.getElementById("TableContent").style.width = CWidth;
        document.getElementById("TheTable").style.height = CHeight;
        document.getElementById("TheTable").style.width = CWidth; TheTable
    }


    //IE6版本提醒
    $(function () {
        if ($.browser.msie && $.browser.version < 7)
            $('#top').before(
             '<div id="ie6detect">' +
             '系统检测发现您正在使用低版本IE浏览器。<br />该版本的浏览器可能存在安全隐患，强烈推荐您在windows系统使用更快速、更安全、更稳定的新版本浏览器.<br />我们推荐您使用Internet Explorer 8以上版本、Google Chrome或者Mozilla FireFox！！'
             + '</div>'
            );
    });




}
);




/*HYQing
==============================================================================================================
*/

//导航栏控制

//初始化
var def = "1";
function mover(object) {
    //主菜单
    var mm = document.getElementById("m_" + object);
    mm.className = "m_li_a";
    //初始主菜单先隐藏效果
    if (def != 0) {
        var mdef = document.getElementById("m_" + def);
        mdef.className = "m_li";
    }
    //子菜单
    var ss = document.getElementById("s_" + object);
    ss.style.display = "block";
    //初始子菜单先隐藏效果
    if (def != 0) {
        var sdef = document.getElementById("s_" + def);
        sdef.style.display = "none";
    }
}

function mout(object) {
    //主菜单
    var mm = document.getElementById("m_" + object);
    mm.className = "m_li";
    //初始主菜单还原效果
    if (def != 0) {
        var mdef = document.getElementById("m_" + def);
        mdef.className = "m_li_a";
    }
    //子菜单
    var ss = document.getElementById("s_" + object);
    ss.style.display = "none";
    //初始子菜单还原效果
    if (def != 0) {
        var sdef = document.getElementById("s_" + def);
        sdef.style.display = "block";
    }
}

function switchmodTag(modtag, modcontent, modk) {
    for (i = 1; i < 9; i++) {
        if (i == modk) {
            document.getElementById(modtag + i).className = "menuOn"; document.getElementById(modcontent + i).className = "slidingList";
        }
        else {
            document.getElementById(modtag + i).className = "menuNo"; document.getElementById(modcontent + i).className = "slidingList_none";
        }
    }
}




//输出日期
function writeDateInfo() {
    var day = "";
    var month = "";
    var ampm = "";
    var ampmhour = "";
    var myweekday = "";
    var year = "";
    mydate = new Date();
    myweekday = mydate.getDay();
    mymonth = mydate.getMonth() + 1;
    myday = mydate.getDate();
    myyear = mydate.getYear();
    year = (myyear > 200) ? myyear : 1900 + myyear;
    if (myweekday == 0)
        weekday = " 星期日";
    else if (myweekday == 1)
        weekday = " 星期一";
    else if (myweekday == 2)
        weekday = " 星期二";
    else if (myweekday == 3)
        weekday = " 星期三";
    else if (myweekday == 4)
        weekday = " 星期四";
    else if (myweekday == 5)
        weekday = " 星期五";
    else if (myweekday == 6)
        weekday = " 星期六";
    document.write(year + "年" + mymonth + "月" + myday + "日" + weekday);
}
//设为首页
function myhomepage() {

    if (document.all) {
        document.body.style.behavior = 'url(#default#homepage)';
        document.body.setHomePage(window.location.href);
    } else if (window.sidebar) {
        if (window.netscape) {
            try {
                netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
            }
            catch (e) {
                alert("此操作被浏览器拒绝！请在浏览器地址栏输入'about:config'并回车然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。");
            }
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
            prefs.setCharPref('browser.startup.homepage', 'http://xxx');
        }
    }
}


//浏览器中自适应居中
function rs() {
    divtomove.style.posLeft = (document.body.clientWidth - divtomove.offsetWidth) / 2;
}

//添加到收藏
//function addfavorite() {
//    if (document.all) {
//        window.external.addFavorite('http://www.baidu.com/#', '国土资源部实物地质资料中心');
//    }
//    else if (window.sidebar) {
//        window.sidebar.addPanel('国土资源部实物地质资料中心', 'http://www.baidu.com/#', "");
//    }
//}

var addFavoritePage = function (obj, url, title) {
    var e = window.event || arguments.callee.caller.arguments[0];
    var B = {
        IE: /MSIE/.test(window.navigator.userAgent) && !window.opera
        , FF: /Firefox/.test(window.navigator.userAgent)
        , OP: !!window.opera
    };
    obj.onmousedown = null;
    if (B.IE) {
        obj.attachEvent("onmouseup", function () {
            try {
                window.external.AddFavorite(url, title);
                window.event.returnValue = false;
            } catch (exp) { }
        });
    } else {
        if (B.FF || obj.nodeName.toLowerCase() == "a") {
            obj.setAttribute("rel", "sidebar"), obj.title = title, obj.href = url;
        } else if (B.OP) {
            var a = document.createElement("a");
            a.rel = "sidebar", a.title = title, a.href = url;
            obj.parentNode.insertBefore(a, obj);
            a.appendChild(obj);
            a = null;
        }
    }
};


function addBookmark(title, url) {
    if (window.sidebar) {
        window.sidebar.addPanel(title, url, "");
    } else if (document.all) {
        window.external.AddFavorite(url, title);
    } else if (window.opera && window.print) {
        return true;
    }
}




/*HYQing   table的奇数和偶数显示不同颜色
==============================================================================================================
*/
function TableStyle() { //页面所有元素加载完毕
    var item = document.getElementById("TheTable");            //获取id为tb的元素(table)
    var trs = item.getElementsByTagName("tr");            //获取tbody元素下的所有tr元素
    for (var i = 0; i < trs.length; i++) {//循环tr元素
        if (i % 2 == 0) {        //取模. (取余数.比如 0%2=0 , 1%2=1 , 2%2=0 , 3%2=1)
            trs[i].style.backgroundColor = "#f0f5f8"; // 改变 符合条件的tr元素 的背景色.

        }
    }
}




/*弹出矿种、矿区的函数
=============================================================================================
*/
var iWidth = 640; //弹出窗口的宽度;
var iHeight = 470; //弹出窗口的高度;
var iTop = (window.screen.availHeight - 30 - iHeight) / 2; //获得窗口的垂直位置;
var iLeft = (window.screen.availWidth - 10 - iWidth) / 2; //获得窗口的水平位置;

function showUploadDialog() {
    var arr = showModalDialog("UserControl/MineName.aspx", window, "dialogWidth:" + iWidth + "px;dialogHeight:" + iHeight + "px;dialogTop:" + iTop + "px;dialogLeft:" + iLeft + "px;help:no;scroll:no;status:no");
}

function showUploadDialogt() {
    var arr = showModalDialog("UserControl/XZArea.aspx", window, "dialogWidth:" + iWidth + "px;dialogHeight:" + iHeight + "px;dialogTop:" + iTop + "px;dialogLeft:" + iLeft + "px;help:no;scroll:no;status:no");
}
